/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pio.action.administrador;

//import DB_OBSOLETA.AspiranteFormDB;
import DBMS.DataBaseManager;
import clases.Aspirante;
import clases.Institucion;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

/**
 *
 * @author charles
 */
public class ModificarAspirante extends DispatchAction {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";
    private static final String FAILURE = "failure";

    public ActionForward populate(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Aspirante aspirante = (Aspirante) form;
        request.setAttribute("instituciones", Institucion.getAll());
        DataBaseManager dbms = DataBaseManager.getInstance();
            return mapping.findForward(SUCCESS);
    }

    public ActionForward update(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Aspirante aspirante = (Aspirante) form;
        request.setAttribute("instituciones", Institucion.getAll());
        DataBaseManager dbms = DataBaseManager.getInstance();
        if (dbms.modificarAspirante(aspirante)) {
            aspirante.setMensaje("Estudiante modificado con exito");
            return mapping.findForward(SUCCESS);
        } else {
            aspirante.setMensaje("No se pudo modificar el aspirante");
            return mapping.findForward(FAILURE);
        }
    }
}
